Skip to content

feat: add a Vercel subproject built on the AI SDK for Python and AI Gateway - #343

Open
zimeg wants to merge 24 commits into
mainfrom
vercel-subproject
Open

zimeg wants to merge 24 commits into
mainfrom
vercel-subproject

Conversation

@zimeg

@zimeg zimeg commented Dec 2, 2026

Copy link
Copy Markdown
Member

Summary

This pull request adds a vercel-ai-sdk/ directory: Casey built on the AI SDK for Python with models through Vercel AI Gateway, which runs locally with slack run and deploys to Vercel over HTTP.

  • It behaves in Slack like claude-agent-sdk/, openai-agents-sdk/ and pydantic-ai/: App Home with the issue categories and modal, DMs, channel mentions with one conversation per person in a thread, suggested prompts, the five IT tools, emoji reactions, marking an issue resolved, feedback buttons, and the Slack MCP Server once someone installs with OAuth.
  • app.py runs in Socket Mode for slack run. app_vercel.py builds the same AsyncApp for HTTP with OAuth and serves it with Bolt's ASGI adapter, and pyproject.toml names it in [tool.vercel] entrypoint, since Vercel would otherwise pick up app.py. Like the siblings, it sets ignoring_self_events_enabled=False so the issue the bot posts from the modal reaches the message listener.
  • app_mention and message are lazy listeners, so Slack gets its acknowledgment right away. On Vercel, a small lazy listener runner in app_vercel.py hands each lazy listener to wait_until so the function stays alive until the agent finishes.
  • The agent uses ai.Agent on anthropic/claude-sonnet-5.5. On Vercel, AI Gateway uses the deployment's OIDC token, so there's no model key to manage. Locally it reads AI_GATEWAY_API_KEY. This app needs Python 3.12 or later, which the AI SDK for Python requires.
  • Conversation history and OAuth state are kept in Runtime Cache, which falls back to memory outside Vercel. OAuth installations are kept in a private Vercel Blob store. With no stored installation, it falls back to SLACK_BOT_TOKEN only for that token's own team.
  • The Vercel files match the Starter Agent's vercel-ai-sdk/ from slack-samples/bolt-python-starter-agent#286, including its review fixes. The dev extra lists its test pins itself, so pip install -e ".[dev]" works after slack create renames the project.
  • The README follows the siblings and adds "OAuth with vercel dev", which runs the same entry point with npx vercel dev and ngrok in place of the siblings' OAuth server, and "Deploy to Vercel". .vercelignore keeps a local .env out of deploys. The root README, AGENTS.md, CI matrices and Dependabot now include vercel-ai-sdk.

Testing

The following ran on a test Vercel project and a test workspace:

  • slack create my-casey-agent --template slack-samples/bolt-python-support-agent --branch vercel-subproject --subdir vercel-ai-sdk, then pip install -e ".[dev]", ruff check, ruff format --check and pytest (42 tests) in the new project.
  • After npx vercel deploy --prod from that project, /slack/install returns 200, an unsigned event gets 401, and project files like /app_vercel.py and /.env return 404.
  • On an earlier build of this branch, Slack accepted https://<project>.vercel.app/slack/events as the request URL, and signed DM events to the deployment got a reaction, a system status answer through AI Gateway with feedback buttons, and a follow-up that remembered the thread. The cold-start acknowledgment took 2.1 seconds.

Still to check by hand, and these need a person in Slack:

  • Send a DM and an @mention in a channel, and use a suggested prompt in the assistant panel.
  • Pick an issue category in App Home, submit the modal, and confirm Casey answers in the DM.
  • Open /slack/install on the deployment, install with OAuth, then ask Casey to search Slack so it uses the Slack MCP Server.
  • Click both feedback buttons.

🤖 Generated with Claude Code

zimeg and others added 21 commits November 18, 2026 00:06
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
- Add vercel/README.md from the claude-agent-sdk README with AI Gateway setup and a Deploy to Vercel section
- Point the App Home MCP link at vercel/README.md
- List vercel in the root README, AGENTS.md, CI matrices, Dependabot and the vendor-bolt commands

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Name the directory after its agent framework, like claude-agent-sdk, openai-agents-sdk and pydantic-ai.

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Document running the same HTTP and OAuth entry point on your machine with `npx vercel dev` and ngrok, so the Slack MCP Server can be tried before deploying, like the siblings' OAuth server.

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
…ence

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
It's only used by the Vercel entry point.

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Co-authored-by: William Bergamin <25348381+WilliamBergamin@users.noreply.github.com>
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
This also logs at info level on the vercel entry point and names the bot token fallback in place of comments.

Co-authored-by: Michael Brooks <21328+mwbrooks@users.noreply.github.com>
Co-authored-by: William Bergamin <25348381+WilliamBergamin@users.noreply.github.com>
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Co-authored-by: Michael Brooks <21328+mwbrooks@users.noreply.github.com>
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Co-authored-by: William Bergamin <25348381+WilliamBergamin@users.noreply.github.com>
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Co-authored-by: William Bergamin <25348381+WilliamBergamin@users.noreply.github.com>
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
…ed Slack skills

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Co-authored-by: William Bergamin <25348381+WilliamBergamin@users.noreply.github.com>
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
…ck CLI

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
@zimeg zimeg added the enhancement New feature or request label Dec 2, 2026
@zimeg zimeg self-assigned this Dec 2, 2026
@zimeg
zimeg marked this pull request as ready for review December 3, 2026 01:24
@zimeg
zimeg requested a review from a team as a code owner December 3, 2026 01:24
@zimeg
zimeg requested review from WilliamBergamin and mwbrooks and removed request for WilliamBergamin and mwbrooks December 3, 2026 01:24

@mwbrooks mwbrooks left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @zimeg, this lines up really closely with the starter agent and the siblings, and the deploy testing in the description is great to see! I will approve once the hand checks in the Testing section are done, since the issue modal flow on Vercel is the one new path here.

),
# Allow bot-posted messages (e.g. issue modal submissions with metadata)
# to reach the message handler instead of being silently dropped
ignoring_self_events_enabled=False,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question (blocking): Has the App Home issue modal had a run on the Vercel deployment yet? This is the one change from the starter agent's app_vercel.py, and with the OAuth install it is still open in the checklist, so I'd like to see both work before approving.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧪 Not yet! The deploy runs this branch's head (6d5c182) now. The signed DM events earlier went through the Vercel handler, but they didn't cover the modal or the OAuth install, and both need a person in Slack. They're next, and I'll follow up here with the results.

Comment thread vercel-ai-sdk/pyproject.toml Resolved
Co-authored-by: Michael Brooks <21328+mwbrooks@users.noreply.github.com>
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>

@cchensh cchensh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked at 6d5c182.

  • Matches the starter: the Vercel infra is byte-identical to bolt-python-starter-agent's vercel-ai-sdk/ (app_vercel.py differs only by ignoring_self_events_enabled=False), and 6d5c182 brings the pins up to the starter and siblings.
  • Matches claude-agent-sdk: Casey's behavior matches, including the lazy listeners and MCP only with a user token.
  • Security: Blob keys can't cross teams or users, the SLACK_BOT_TOKEN fallback refuses other teams, and OAuth state is single-use with a TTL.
  • Lazy runner: wait_until gets a scheduled task, with one ack per event.

Should-fix

  • The starter's ExceptionGroup unwrap (bolt-python-starter-agent#321) isn't ported. agent/casey.py calls ai.Agent(...).run and ai.mcp.get_http_tools directly, and ai==0.10.0 runs them in an asyncio.TaskGroup. An expired MCP user token or an AI Gateway error therefore reaches app_mentioned.py:92 / message.py:115 as :warning: Something went wrong! (unhandled errors in a TaskGroup (1 sub-exception)) instead of the real error. Suggest porting _run / _only_error and the starter's tests/test_agent.py.

Nit

  • skills-lock.json records ref: v1.9.0 / 5efa92b from the starter, while the siblings pin 766e933. The vendored skills are identical.

@WilliamBergamin WilliamBergamin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🪞 Thanks @zimeg! Reusing the starter's reviewed Vercel layer and keeping the listeners in lockstep with the siblings makes this big diff easy to trust.
One blocking comment on how agent errors reach the user, the other is optional 🙏

Comment thread vercel-ai-sdk/agent/casey.py Resolved
Comment thread vercel-ai-sdk/app_vercel.py Resolved
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Co-authored-by: William Bergamin <25348381+WilliamBergamin@users.noreply.github.com>
Co-authored-by: Cheng Chen <35309699+cchensh@users.noreply.github.com>
@zimeg

zimeg commented Dec 3, 2026

Copy link
Copy Markdown
Member Author

🔧 @cchensh the TaskGroup unwrap is ported in a1901db, with the starter's error tests. The skills-lock.json ref is the same as on Casey JS: the siblings' 766e933 is 3 commits behind v1.9.0 with the same skill files, and slack-samples/bolt-js-support-agent#185 (comment) has why the daily skills workflow leaves it.

@WilliamBergamin WilliamBergamin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for porting this so quickly! 🙏 The unwrap now matches the starter agent's, and against an unreachable MCP URL I see ConnectError: All connection attempts failed instead of the TaskGroup message. The two new tests in tests/test_agent.py would fail without the fix, and they pass for me locally along with the rest of the suite, ruff check and ruff format --check. I left one small note inline.

Comment thread vercel-ai-sdk/agent/casey.py Resolved
@WilliamBergamin
WilliamBergamin dismissed their stale review December 3, 2026 17:34

The blocking concerns are resolved; see the latest review.

@zimeg
zimeg requested a review from WilliamBergamin December 4, 2026 00:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants